<template>
	<view class="mx-view column">
		<view class="u-f-32 font-weight-550">金豆明细</view>
		<view class="mx-item bg-f u-bdr-12 u-m-t-20 u-p-l-24 u-p-r-36 space-between" v-for="(item,index) in list" :key="index" >
			<view class="column h-100 space-evenly">
				<view class="u-f-28">{{item.title}}</view>
				<view class="w-s-color-9 u-f-22">{{item.createTime}}</view>
			</view>
			<view class="u-f-32 font-weight-550">{{item.type==1?'+':'-'}}{{item.money}}</view>
		</view>
		<view v-if="list.length > 0" class="u-m-t-20">
			<u-loadmore :status="status" />
		</view>
		<view class="u-flex-1 flex-center" v-if="list.length==0" >
			<empty title="暂无明细" />
		</view>
	</view>
</template>

<script>
	
	import empty from '../../components/empty.vue'
	export default {
		components: {
			empty,
		},
		data() {
			return {
				status: 'loadmore',
				list: [], //余额明细
				page: 1,
				pages: 1,
				limit: 10,
			};
		},
		onLoad() {
			this.getList()
		},
		//我是有底线的
		onReachBottom() {
			if (this.page < this.pages) {
				this.page += 1
				this.status = 'loading'
				this.getList()
			} else {
				this.status = 'nomore'
			}
		},
		onPullDownRefresh() {
			this.page = 1
			this.getList()
		},
		methods: {
			getList() {
				let data = {
					page: this.page,
					limit: this.limit
				}
				this.$Request.getT('/app/moneyDetails/queryUserMoneyDetails', data).then(res => {
					uni.stopPullDownRefresh()
					if (res.code == 0) {
						this.pages = res.data.pages
						if (this.page < this.pages) {
							this.status = 'loadmore'
						} else {
							this.status = 'nomore'
						}
						if (this.page == 1) {
							this.list = res.data.records
						} else {
							this.list = [...this.list, ...res.data.records]
						}
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	page{
		background: #F7F8FF;
	}
	.mx-view{
		width: 100vw;
		min-height: 100vh;
		padding: 20rpx 32rpx;
		padding-bottom: calc(20rpx + constant(safe-area-inset-bottom));
		padding-bottom: calc(20rpx + env(safe-area-inset-bottom));
		.mx-item{
			height: 140rpx;
		}
	}
</style>